import Vue from 'vue'
import Vuex from 'vuex'
import stateIndex from './stateIndex';
import gettersIndex from './gettersIndex'
import actionIndex from './actionIndex'
Vue.use(Vuex);
const store = new Vuex.Store({
  modules: {
    stateIndex,
    gettersIndex,
    actionIndex
  }
})
export default store;

/**
 state
 state: {
    todos: [
      { id: 1, done: true },
      { id: 2, done: false }
    ]
  },
 getters: {
    doneTodos: state => {
      return state.todos.filter(todo => todo.done)
    },
  },
 mutations: {
    mutDoneTodos(state, state1) {
      state.todos.push({
        id: new Date().getTime(), done: true, idS: state1
      })
      console.log(state, state1)
    }
  }
 * */

/**
 getters
 state: {
    todos: [
      { id: 1, done: true },
      { id: 2, done: false }
    ],
    getTodo: [
      { id: 1, done: true },
      { id: 2, done: false }
    ],
    getterLength: 1,
  },
 getters: {
    doneTodos: state => {
      return state.todos.filter(todo => todo.done)
    },
    getLength: (state, getters) => {
      return state.getterLength
    },
    getNum: (state) => (id) => {
      console.log(state);
      console.log(id);
      return state.getTodo.find(todo => todo.id === id)
    }
  },
 mutations: {
    mutDoneTodos(state, state1) {
      state.todos.push({
        id: new Date().getTime(), done: true
      })
    },
    mutLength(state) {
      state.getterLength++;
    },
    mutNum(state) {
      state.getTodo.push({
        id: 4, done: true
      })
    }
  }
 * */
